package com.sugon.cloudalibabapayment.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.Locale;

/**
 * payment 控制器
 *
 * @author JH
 * @version 1.0
 * @since 2023/2/20 11:41
 */

@RestController
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;

    @GetMapping(value = "/payment/nacos/{id}")
    public String getPayment(@PathVariable("id")Integer id) {
        return "nacos registry, serverPort: " + serverPort + "\t id: " + id;
    }

    @GetMapping(value = "/payment/get/{id}")
    public String gwPayment(@PathVariable("id") Long id) {
        return "gateway test, actual ServerPort: " + serverPort + "\t id: " + id;
    }

    @GetMapping(value = "/payment/lb")
    public String lbPayment() {
        return "nacos registry, serverPort: " + serverPort;
    }

    @GetMapping(value = "/payment/show")
    public String show(HttpServletRequest request, String code) {
        //log.info("验证 filter 的 AddRequestParameter 功能:{}", code);
        return "Spring cloud gateway predicate after and before test " + LocalDateTime.now();
    }
}
